package com.eshipenet.shipnet.equipmentdatahub

import java.lang

import org.apache.flink.streaming.connectors.kafka.KafkaSerializationSchema
import org.apache.kafka.clients.producer.ProducerRecord

class EquipmentDataKafkaSerializer extends KafkaSerializationSchema[EquipmentData] {

  override def serialize(element: EquipmentData, timestamp: lang.Long): ProducerRecord[Array[Byte], Array[Byte]] = {
    val topic = "EquipmentData"
    val key   = element.model.id.getBytes()
    val value = element.toJson.toString().getBytes()
    new ProducerRecord(topic, key, value)
  }

}
